package com.vhall.autotest.api_test.service;

import java.util.HashMap;
import java.util.Map;

import org.junit.Assert;

import com.alibaba.fastjson.JSONObject;
import com.vhall.autotest.api_test.common.Constant;
import com.vhall.autotest.api_test.common.HttpUtil;
import com.vhall.autotest.api_test.service.code.ICode;

public class Report {
	private static final String reportSignUrl = Constant.apiDomain + "/api/vhallapi/v2/report/sign";
	private static final String reportSignRecordUrl = Constant.apiDomain + "/api/vhallapi/v2/report/sign-record";
	public static Map<String, String> reportSign_success(String webinar_id, String pos, String limit) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(pos != null){
			param.put("pos", pos);
		}
		if(limit != null){
			param.put("limit", limit);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(reportSignUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("reportSign_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> reportSignRecord_success(String sign_id, String pos, String limit) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(sign_id != null){
			param.put("sign_id", sign_id);
		}
		if(pos != null){
			param.put("pos", pos);
		}
		if(limit != null){
			param.put("limit", limit);
		}
		
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(reportSignRecordUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("reportSignRecord_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
}
